//
//  Doctor.m
//  Doctor1.0
//
//  Created by mk on 15/5/30.
//  Copyright (c) 2015年 cocoa-mk. All rights reserved.
//

#import "Doctor.h"

@implementation Doctor

-(instancetype)initWithDictionary:(NSMutableDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}
-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{

    if ([key isEqualToString:@"id"]) {
        self.ID = value;
    }
}


-(id)valueForUndefinedKey:(NSString *)key
{
    return nil;
}


-(id)init
{
    if (self = [super init])
    {
        self.urlPath = @"";
         self.strDataKey = requestDataKey;
    }
    return self;
}

#pragma mark 设置DATA
-(void)parseData:(id)dataObj
{
    [super parseData:dataObj];
    
    if ([dataObj isKindOfClass:[NSDictionary class]])
    {
        self.ID =  NullObjToString(dataObj[@"id"]);
        self.name = NullObjToString(dataObj[@"name"]);
        self.mTitle = NullObjToString(dataObj[@"mTitle"]);
        self.aTitle = NullObjToString(dataObj[@"aTitle"]);
        self.imageUrl = NullObjToString(dataObj[@"imageUrl"]);
        self.hpId = NullObjToString(dataObj[@"hpId"]);
        self.hpName = NullObjToString(dataObj[@"hpName"]);
        self.hpDeptId = NullObjToString(dataObj[@"hpDeptId"]);
    
        if(NullObjToString(dataObj[@"hpDeptName"]).length>0)
          self.hpDeptName = NullObjToString(dataObj[@"hpDeptName"]);
        else
          self.hpDeptName = NullObjToString(dataObj[@"hpDept"]);
        
        self.actionUrl = @"";
        NSString* strDate = NullObjToString(dataObj[@"actionUrl"]);
        self.actionUrl = strDate;
        
        strDate = NullObjToString(dataObj[@"isContracted"]);
        if (strDate)
            self.isContracted = strDate;
        
        
        self.desc = NullObjToString(dataObj[@"desc"]);
        
    }


}
@end


@implementation DoctorListData

-(id)init
{
    if (self = [super init])
    {
        self.urlPath = @"";
        self.strDataKey = requestDataKey;
    }
    return self;
}

-(void)parseData:(id)dataObj
{
    [super parseData:dataObj];
    
    if ([dataObj isKindOfClass:[NSArray class]])
    {
        for (int i = 0; i < [dataObj count]; i++) {
            NSDictionary *dicRec = [dataObj objectAtIndex:i];
            Doctor *recData = [[Doctor alloc] init];
            [recData parseData:dicRec];
            [self.dataArray addObject:recData];
        }
    }
}


@end

















